﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Special 的摘要说明
/// </summary>
public class Special
{
    public Special()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }


    private string guid;
    private string name;
    private string type;
    private string time;
    private string lat;
    private string lon;
    private string remark;

    public string Guid
    {
        get
        {
            return guid;
        }

        set
        {
            guid = value;
        }
    }

    public string Name
    {
        get
        {
            return name;
        }

        set
        {
            name = value;
        }
    }

    public string Type
    {
        get
        {
            return type;
        }

        set
        {
            type = value;
        }
    }

    public string Time
    {
        get
        {
            return time;
        }

        set
        {
            time = value;
        }
    }

    public string Lat
    {
        get
        {
            return lat;
        }

        set
        {
            lat = value;
        }
    }

    public string Lon
    {
        get
        {
            return lon;
        }

        set
        {
            lon = value;
        }
    }

    public string Remark
    {
        get
        {
            return remark;
        }

        set
        {
            remark = value;
        }
    }

    /// <summary>
    /// 获取一个专题
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public Special getSpecial(string id)
    {
        Special special = new Special();
        string sql = "select * from special where guid = '" + id + "'";
        DataRow dr = myMysql.ExecuteDataTable(sql).Rows[0];
        special.Guid = dr["guid"].ToString();
        special.Name = dr["name"].ToString();
        special.Type = dr["type"].ToString();
        special.Lat = dr["lat"].ToString();
        special.Lon = dr["lon"].ToString();
        special.Time = dr["time"].ToString();
        special.Remark = dr["remark"].ToString();
        return special;
    }

    public bool addSpecial(Special special)
    {
        try
        {
            string sql = "insert into special (guid,name,type,lat,lon,time,remark) values ('" + special.guid
           + "','" + special.name + "','" + special.type + "','" + special.lat + "','" + special.lon + "','" + special.time + "','" + special.remark + "')";
            if (myMysql.ExecuteNonQuery(sql) == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception)
        {

            return false;
        }       
    }

    public bool removeSpecial(string id)
    {
        string sql = "delete from special where id = '" + id + "'";
        try
        {
            if (myMysql.ExecuteNonQuery(sql) == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception)
        {

            return false;
        }
    }
}